package fortunata.fswapps.vpoet;

import fortunata.fswapps.vpoet.VPOETRequestData;

/**
 * This is specific for GG (Google Gadgets). This class just redefines some parameters to the GG flavor and
 * reuses the logics of its base class.
 */
public class VPOETRequestGGData extends VPOETRequestData {
     static final public String gGprefix = "up_";
     public VPOETRequestGGData(String url){
        super(url);
        //Reasign param names only if they are not assigned yet
        if (!paramNameAction.startsWith(gGprefix)) {
            paramNameAction = gGprefix + paramNameAction;
            paramNameOntoElemID = gGprefix + super.paramNameOntoElemID;
            paramNameOutFormat = gGprefix + super.paramNameOutFormat;
            paramNameProvider = gGprefix + super.paramNameProvider;
            paramNameDesignID = gGprefix + super.paramNameDesignID;
            paramNameSource = gGprefix + super.paramNameSource;
            paramNameIndvID = gGprefix + super.paramNameIndvID;
        }
     }
    static public void main(String[] args){
           String urlStr1 = "http://localhost/fortunata/servlet/VPoetRequestGGServlet?up_action=renderOutput"+
                           "&up_designID=SimpleFOAFOutputConditional"+
                           "&up_provider=mra68"+
                           "&up_source=http://www.w3.org/People/Berners-Lee/card";
           VPOETRequestGGData r = new VPOETRequestGGData(urlStr1);
//           r.getRequestForRelation("http://www.ii.uam.es/~mrico/foaf.rdf",
//                                   "",
//                                   ""
//                                   );
          System.out.println("Original request:\n" + r.niceDisplay(urlStr1));
          String idvStr1 = "http%3A%2F%2Fdbpedia.org%2Fresource%2FTim_Bray";
          String res1 = r.getRequestForIndividual(idvStr1);
          System.out.println("After getRequestForIndividual("+ idvStr1 +"):\n" + r.niceDisplay(res1));

          String urlStr2 = "http://localhost/fortunata/servlet/VPoetRequestGGServlet?up_action=renderOutput"+
                           "&up_designID=SimpleFOAFOutputConditional"+
                           "&up_provider=mra68"+
                           "&up_source=http://www.w3.org/People/Berners-Lee/card" +
                           "&up_indvID=http%3A%2F%2Fwww.w3.org%2FPeople%2FBerners-Lee%2Fcard%23i";

          System.out.println("Original request:\n" + r.niceDisplay(urlStr2));
          try {
             String idvStr2 = "http%3A%2F%2Fhometown.aol.com%2Fchbussler%2Ffoaf%2Fchbussler.foaf%23me";
             String res2 = r.getRequestForSource(idvStr2);
             System.out.println("After getRequestForSource("+ idvStr2+ "):\n" + r.niceDisplay(res2));
          }catch(Exception e){
              System.out.println("Wrong URI!");
          }

     }

}
